Skip to content

feat(version): add MANUAL_VERSION, --next and --patch to version command#1724

Merged
bearomorphism merged 6 commits intocommitizen-tools:masterfrom
bearomorphism:feat-next-version
May 3, 2026
Merged

feat(version): add MANUAL_VERSION, --next and --patch to version command#1724
bearomorphism merged 6 commits intocommitizen-tools:masterfrom
bearomorphism:feat-next-version

Conversation

@bearomorphism
Copy link
Copy Markdown
Collaborator

@bearomorphism bearomorphism commented Dec 12, 2025

Closes #1679

Manually tested and added test cases, the result LGTM.

@bearomorphism
Copy link
Copy Markdown
Collaborator Author

@Lee-W I already ran pytest tests/commands/test_version_command.py -n auto --regen-all to regenerate the test files, but the pipeline still fails. (The tests passed on my machine)

Do you have any ideas why this happen

Comment thread commitizen/commands/version.py
@woile
Copy link
Copy Markdown
Member

woile commented Dec 12, 2025

There was a way to run all the pre-commits, but I don't remember how it works 😅

Comment thread tests/commands/test_version_command.py Outdated
Comment thread tests/commands/test_version_command.py
Comment thread commitizen/commands/version.py Outdated
@woile
Copy link
Copy Markdown
Member

woile commented Dec 12, 2025

Nice to see this going forward 🎉

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.10%. Comparing base (69884e0) to head (2ca5b7e).
⚠️ Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1724      +/-   ##
==========================================
+ Coverage   97.99%   98.10%   +0.11%     
==========================================
  Files          60       61       +1     
  Lines        2691     2746      +55     
==========================================
+ Hits         2637     2694      +57     
+ Misses         54       52       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bearomorphism
Copy link
Copy Markdown
Collaborator Author

@Lee-W I already ran pytest tests/commands/test_version_command.py -n auto --regen-all to regenerate the test files, but the pipeline still fails. (The tests passed on my machine)

Do you have any ideas why this happen

I see why the test failure happens. Please see my other PR #1726 .

@bearomorphism
Copy link
Copy Markdown
Collaborator Author

I will rebase this branch after #1726 is merged. The test failure should be resolved then.

@bearomorphism bearomorphism force-pushed the feat-next-version branch 3 times, most recently from 8d938d2 to f9afbd4 Compare December 14, 2025 14:08
@bearomorphism bearomorphism changed the base branch from v4-11-0 to master December 29, 2025 11:11
@bearomorphism bearomorphism force-pushed the feat-next-version branch 3 times, most recently from 3b48a33 to b07121e Compare January 3, 2026 17:24
Copy link
Copy Markdown
Member

@noirbizarre noirbizarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting feature, one that I would totally use!

Also, I never realized that the version command was doing totally different things depending on the flags 😅
So maybe it's the occasion to have a dedicated --version flag and have the version command focusing on the the project versioning and not the Commitizen version. It would be cleaner, easier to understand and more standard. WDYT ?

Note

I would not remove the Type aliases as it makes the PR bigger than it should and it introduce a breaking change (and reading the PR and issues, we know that it has been used by some users for some custom version schemes).

Comment thread commitizen/version_schemes.py Outdated
Comment thread commitizen/version_increment.py Outdated
Comment thread commitizen/version_increment.py
@noirbizarre
Copy link
Copy Markdown
Member

Also, the enumn part seems to overlap with #1518, so maybe #1518 should go first so this PR can reuse the Increment enum

@bearomorphism
Copy link
Copy Markdown
Collaborator Author

Also, the enumn part seems to overlap with #1518, so maybe #1518 should go first so this PR can reuse the Increment enum

I would prefer to merge this before #1518 because it is a bit larger than this PR.

So maybe it's the occasion to have a dedicated --version flag and have the version command focusing on the the project versioning and not the Commitizen version. It would be cleaner, easier to understand and more standard. WDYT ?

+1. As a user, I often run cz --version and end up seeing an error. We can create another work item about adding the dedicated flag and then deprecate cz version --commitizen and other removable flags in the next major version.

@woile
Copy link
Copy Markdown
Member

woile commented Jan 5, 2026

We had a --version in the past, but it was replaced by version, do you remember why @Lee-W ?
It would be a breaking change if we go that route. If agreed, I can add it as a different task on the parent issue tracking this work #1677

@bearomorphism bearomorphism marked this pull request as ready for review January 6, 2026 13:26
@bearomorphism bearomorphism force-pushed the feat-next-version branch 2 times, most recently from 4b6a441 to c3d27c9 Compare January 6, 2026 14:01
@bearomorphism bearomorphism changed the title feat(version): add MANUAL_VERSION, --next and --patch to version comm… feat(version): add MANUAL_VERSION, --next and --patch to version command Jan 6, 2026
@bearomorphism
Copy link
Copy Markdown
Collaborator Author

@woile @noirbizarre @Lee-W
Could you review and merge this PR, so we can move on to other cz version related task? Thanks!

@woile
Copy link
Copy Markdown
Member

woile commented Jan 12, 2026

There are some open conversations still

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new capabilities to the cz version command to support experimenting with version schemes by supplying a manual version, computing the “next” version, and outputting the patch component, with updated CLI help artifacts and tests.

Changes:

  • Add MANUAL_VERSION positional arg plus --next and --patch options to cz version.
  • Introduce VersionIncrement enum to model bump increments used by --next.
  • Update tests and CLI help snapshots/docs assets to reflect the new interface.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
commitizen/commands/version.py Implements MANUAL_VERSION, --next, and --patch behaviors in the version command.
commitizen/cli.py Adds new CLI arguments/help text and updates usage for cz version.
commitizen/version_increment.py Introduces VersionIncrement enum + helper casting used by --next.
commitizen/version_schemes.py Adjusts typing around schemes/protocols and scheme loading.
commitizen/tags.py Updates scheme/version typing usage within tag utilities.
commitizen/out.py Broadens output helpers to accept non-string values safely.
commitizen/commands/init.py Updates type hints to use VersionProtocol.
commitizen/bump.py Updates type hints to use VersionProtocol.
tests/commands/test_version_command.py Updates existing assertions and adds new tests for --next + manual version validation.
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_version_.txt Updates CLI help snapshot for Python 3.10.
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_version_.txt Updates CLI help snapshot for Python 3.11.
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_version_.txt Updates CLI help snapshot for Python 3.12.
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_version_.txt Updates CLI help snapshot for Python 3.13.
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_version_.txt Updates CLI help snapshot for Python 3.14.
docs/images/cli_help/cz_version___help.svg Updates rendered CLI help image to match new options.
docs/commands/version.md Touches documentation page for cz version (currently defers details via TODO).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread commitizen/commands/version.py Outdated
Comment thread commitizen/commands/version.py Outdated
Comment thread commitizen/commands/version.py
Comment thread commitizen/version_schemes.py Outdated
Comment thread commitizen/tags.py Outdated
Comment thread commitizen/cli.py
Comment thread commitizen/cli.py
Comment thread tests/commands/test_version_command.py Outdated
Comment thread docs/commands/version.md Outdated
Copy link
Copy Markdown
Member

@woile woile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Maybe @Lee-W do you have any thoughts?

Comment thread commitizen/commands/version.py
…mand

Rebased onto master: keep --tag with TagRules alongside the new flags.

- Merge version command logic for manual/next/patch with tag normalization
- Refresh help regression fixtures and cz version --help SVG
- Fix TagRules.find_tag_for annotation (VersionProtocol)

Closes commitizen-tools#1679

Made-with: Cursor
Argparse wraps the usage line differently before vs after Python 3.13, so
separate regression baselines are required for CI matrix jobs.

Made-with: Cursor
- Rename VersionIncrement.safe_cast to from_value; add tests
- Map NONE to no bump; user-facing error for USE_GIT_COMMITS
- Add tests for patch component, unknown scheme, and default output
- Clarify get_version_scheme Protocol check; fix TagRules docstring example
- Document MANUAL_VERSION, --next, and --patch; refresh help fixtures/SVG

Made-with: Cursor
…ases

Re-export VersionScheme = type[VersionProtocol] and Version = VersionProtocol
for downstream custom schemes and parity with the public API on master.
Import TypeAlias at runtime alongside Increment/Prerelease.

Made-with: Cursor
- Parametrize invalid combination tests (major/minor/patch/tag without project)
- Fix version scheme validation to use hasattr check instead of broken
  isinstance/issubclass on Protocol with non-method members
- Format test file with ruff

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ols#1678)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@woile woile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bearomorphism bearomorphism dismissed noirbizarre’s stale review May 3, 2026 07:00

I believe noirbizarre's blocking comment (unnecessary deletion of VersionScheme) is resolved.

@bearomorphism bearomorphism merged commit b5e0840 into commitizen-tools:master May 3, 2026
20 checks passed
@bearomorphism bearomorphism deleted the feat-next-version branch May 3, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for cz version <version_arg>

4 participants